<?php
/*
#############################################################################
#  Filename: activate.php
#  Create date: Tuesday, March 18, 2008	 06:17:45
#  Project: prethOgame
#  Description: RPG web based game
#
#  Copyright ?2008 Aleksandar Spasojevic <spalekg@gmail.com>
#  Copyright ?2005 - 2008 KGsystem
#############################################################################
*/
define('INSIDE'  , true);
define('INSTALL' , false);
$ugamela_root_path = './';
include($ugamela_root_path . 'extension.inc');
include($ugamela_root_path . 'common.' . $phpEx);

includeLang('activate');

//$dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"];

$regID = $_GET['regID'];

$isexist = doquery("SELECT `passwdurl` FROM {{table}} WHERE `passwdurl` = '".$regID."' LIMIT 1;", 'users', true);

if($isexist){
	$query = doquery("SELECT * FROM {{table}} WHERE `passwdurl` = '".$regID."'", 'users');
	$userdata = mysql_fetch_array($query);
	
	$newpass = $userdata['temp_passwd'];
	$userid = $userdata['id'];
	$QryUpdateUser  = "UPDATE {{table}} SET ";
	$QryUpdateUser .= "`password` = '".$newpass."', ";
	$QryUpdateUser .= "`passwdurl` = '0', ";
	$QryUpdateUser .= "`temp_passwd` = '' ";
	$QryUpdateUser .= "WHERE `id` = '".$userid."' LIMIT 1;";
	doquery($QryUpdateUser, 'users');
//	doquery("UPDATE {{table}} SET `password` = '".$newpass."', `passwdurl` = '0', `temp_passwd` = '0' WHERE `id` = '".$userid."' LIMIT 1;", 'users');

	message($lang['sucess'], $lang['all_done'], "login.php", 1);
}else{
	echo "ERROR";
	message($lang['wrong_data'],$lang['Error'],"login.php", 1);
}
?>
